package com.study.handler;

import org.apache.camel.Exchange;
import org.apache.camel.Handler;
import org.apache.camel.Message;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @author study
 * @version 1.0
 * @date 2020/9/14 15:51
 */
@Component("myUDPOrderHandler")
public class MyUDPOrderHandler {

    public static final ConcurrentHashMap<String, Thread> MAP = new ConcurrentHashMap<>();

    @Handler
    public void handler(Exchange exchange) {
        Message in = exchange.getIn();
        String body = in.getBody(String.class);
        final Thread currentThread = Thread.currentThread();
        System.out.println();
        System.out.println(String.format("接受到的数据：%s 处理的线程是%s", body, currentThread));
        System.out.println(StringUtils.repeat("--", "*", 30));
        for (int i = 0; i < 10; i++) {
            System.out.println(body);

        }
        in.setBody(System.currentTimeMillis() + body + currentThread.getName());
    }

}
